package com.b.dao;

import com.b.domain.Follow;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface FollowMapper {
    /**
     * delete by primary key
     *
     * @param id primaryKey
     * @return deleteCount
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * insert record to table
     *
     * @param record the record
     * @return insert count
     */
    int insert(Follow record);

    /**
     * insert record to table selective
     *
     * @param record the record
     * @return insert count
     */
    int insertSelective(Follow record);

    /**
     * select by primary key
     *
     * @param id primary key
     * @return object by primary key
     */
    Follow selectByPrimaryKey(Integer id);

    /**
     * update record selective
     *
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKeySelective(Follow record);

    /**
     * update record
     *
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKey(Follow record);

    @Select("select * from follow")
    List<Follow> getAll();

    @Select("select * from follow where follower_id=#{followerId} and following_id=#{followingId}")
    Follow findFollowByFollowerIdAndAndFollowingId(@Param("followerId") Integer followerId, @Param("followingId") Integer followingId);

    @Delete("delete from follow where follower_id=#{followerId} and following_id=#{followingId} ")
    void deleteByFollowerIdAndFollowingId(@Param("followerId") Integer followerId, @Param("followingId") Integer followingId);
}